package DEMO;

import org.junit.jupiter.api.Test;

/**
 * @author Lzm
 * @version 1.0
 */
public class demo {
  @Test
  public void test(){
    int n = 1221;
    System.out.println(isDouble(n));
  }

  public boolean isDouble(int n){
    int count = 1;
    int num = n;
    int sum1 = 0;
    int sum2 = 0;
    while(num > 9){
      count++;
      num /= 10;
    }
    if (count % 2 != 0){
      System.out.println(count);
      return false;
    }
    else{
      System.out.println(count);
      int[] nums = new int[count];
      int count2 = count / 2;
      int count3 = count / 2;
      while(count2 > 0){
        nums[count2 - 1] = n % 10;
        n %= 10;
        count2--;
      }
      for(int i = 0 ; i < count3; i ++){
        sum1 += nums[i];
      }
      for(int i =  count3 ; i < count; i ++){
        sum2 += nums[i];
      }
      if (sum1 == sum2){
        System.out.println(sum1);
        System.out.println(sum2);
        return true;
      }
      else{
        System.out.println(sum1);
        System.out.println(sum2);
        return false;
      }
    }
  }
}
